home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTPtrOrderedVector.z / RWTPtrOrderedVector
Encoding:
Text File  |  2002-10-03  |  17.6 KB  |  463 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTPtrOrderedVector<T> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/tpordvec.h>
  13.  
  14.  
  15.  
  16.               RWTPtrOrderedVector<T> ordvec;
  17.  
  18. PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!!
  19.      IIIIffff yyyyoooouuuu ddddoooo nnnnooootttt hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd
  20.      hhhheeeerrrreeee....  OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ttttoooo RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr described in
  21.      the Class Reference.
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  29.      RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr<<<<TTTT>>>> is a pointer-based oooorrrrddddeeeerrrreeeedddd collection.  That is,
  30.      the items in the collection have a meaningful ordered relationship with
  31.      respect to one another and can be accessed by an index number.  The order
  32.      is set by the order of insertion.  Duplicates are allowed.  The class is
  33.      implemented as a vector, allowing efficient insertion and retrieval from
  34.      the end of the collection, but somewhat slower from the beginning of the
  35.      collection.  The class TTTT must have:
  36.           well-defined equality semantics (TTTT::::::::ooooppppeeeerrrraaaattttoooorrrr========((((ccccoooonnnnsssstttt TTTT&&&&))))).
  37.  
  38.  
  39. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  40.      Isomorphic
  41.  
  42.  
  43.  
  44.  
  45.  
  46. EEEExxxxaaaammmmpppplllleeee
  47.               #include <rw/tpordvec.h>
  48.           #include <rw/rstream.h>
  49.           main() {
  50.             RWTPtrOrderedVector<double> vec;
  51.             vec.insert(new double(22.0));
  52.             vec.insert(new double(5.3));
  53.             vec.insert(new double(-102.5));
  54.             vec.insert(new double(15.0));
  55.             vec.insert(new double(5.3));
  56.             cout << vec.entries() << " entries0 << endl;  // Prints "5"
  57.             for (int i=0; i<vec.length(); i++)
  58.               cout << *vec[i] << endl;
  59.             vec.clearAndDestroy();
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.             return 0;
  75.           }
  76.  
  77.  
  78.      Program output:
  79.  
  80.               5 entries
  81.           22
  82.           5.3
  83.           -102.5
  84.           15
  85.           5.3
  86.  
  87.  
  88.               .Ex
  89.  
  90.  
  91. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  92.               RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr<T>(size_t capac=RWDEFAULT_CAPACITY);
  93.  
  94.  
  95.      Creates an empty ordered vector with capacity ccccaaaappppaaaacccc.  Should the number
  96.      of items exceed this value, the vector will be resized automatically.
  97.  
  98.               RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr<T>(const RWTPtrOrderedVector<T>& c);
  99.  
  100.  
  101.      Constructs a new ordered vector as a shallow copy of cccc.  After
  102.      construction, pointers will be shared between the two collections.
  103.  
  104. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  105.               RWTPtrOrderedVector<T>&
  106.           ooooppppeeeerrrraaaattttoooorrrr====(const RWTPtrOrderedVector& c);
  107.  
  108.  
  109.      Sets self to a shallow copy of cccc.  Afterwards, pointers will be shared
  110.      between the two collections.
  111.  
  112.               T*&
  113.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i);
  114.           T* const&
  115.           ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i) const;
  116.  
  117.  
  118.      Returns a pointer to the iiiith value in the vector.  The first variant can
  119.      be used as an llllvvvvaaaalllluuuueeee, the second cannot.  The index iiii must be between
  120.      zero and the number of items in the collection less one.  No bounds
  121.      checking is performed.
  122.  
  123.               T*&
  124.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
  125.           T* const&
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i) const;
  141.  
  142.  
  143.      Returns a pointer to the iiiith value in the vector.  The first variant can
  144.      be used as an llllvvvvaaaalllluuuueeee, the second cannot.  The index iiii must be between
  145.      zero and the number of items in the collection less one, or an exception
  146.      of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will be thrown.
  147.  
  148. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  149.               void
  150.           aaaappppppppeeeennnndddd(T* a);
  151.  
  152.  
  153.      Appends the item pointed to by aaaa to the end of the vector.  The
  154.      collection will automatically be resized if this causes the number of
  155.      items in the collection to exceed the capacity.
  156.  
  157.               T*&
  158.           aaaatttt(size_t i);
  159.           T* const&
  160.           aaaatttt(size_t i) const;
  161.  
  162.  
  163.      Returns a pointer to the iiiith value in the vector.  The first variant can
  164.      be used as an llllvvvvaaaalllluuuueeee, the second cannot.  The index iiii must be between
  165.      zero and the number of items in the collection less one, or an exception
  166.      of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will be thrown.
  167.  
  168.               void
  169.           cccclllleeeeaaaarrrr();
  170.  
  171.  
  172.      Removes all items from the collection.
  173.  
  174.               void
  175.           cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy();
  176.  
  177.  
  178.      Removes all items from the collection aaaannnndddd deletes them.
  179.  
  180.               RWBoolean
  181.           ccccoooonnnnttttaaaaiiiinnnnssss(const T* a) const;
  182.  
  183.  
  184.      Returns TTTTRRRRUUUUEEEE if the collection contains an item that is equal to the
  185.      object pointed to by aaaa, FFFFAAAALLLLSSSSEEEE otherwise.  A linear search is done.
  186.      Equality is measured by the class-defined equality operator for type TTTT.
  187.  
  188.               T* const *
  189.           ddddaaaattttaaaa() const;
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Returns a pointer to the raw data of the vector.  The contents should not
  207.      be changed.  Should be used with care.
  208.  
  209.               size_t
  210.           eeeennnnttttrrrriiiieeeessss() const;
  211.  
  212.  
  213.      Returns the number of items currently in the collection.
  214.  
  215.               T*
  216.           ffffiiiinnnndddd(const T* target) const;
  217.  
  218.  
  219.      Returns a pointer to the first object encountered which is equal to the
  220.      object pointed to by ttttaaaarrrrggggeeeetttt, or nnnniiiillll if no such object can be found.
  221.      Equality is measured by the class-defined equality operator for type TTTT.
  222.  
  223.               T*&
  224.           ffffiiiirrrrsssstttt();
  225.           T* const&
  226.           ffffiiiirrrrsssstttt() const;
  227.  
  228.  
  229.      Returns a pointer to the first item in the vector.  An exception of type
  230.      RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will occur if the vector is empty.
  231.  
  232.               size_t
  233.           iiiinnnnddddeeeexxxx(const T* a) const;
  234.  
  235.  
  236.      Performs a linear search, returning the index of the first object that is
  237.      equal to the object pointed to by aaaa, or RRRRWWWW____NNNNPPPPOOOOSSSS if there is no such
  238.      object.  Equality is measured by the class-defined equality operator for
  239.      type TTTT.
  240.  
  241.               void
  242.           iiiinnnnsssseeeerrrrtttt(T* a);
  243.  
  244.  
  245.      Adds the object pointed to by aaaa to the end of the vector.  The collection
  246.      will be resized automatically if this causes the number of items to
  247.      exceed the capacity.
  248.  
  249.               void
  250.           iiiinnnnsssseeeerrrrttttAAAAtttt(size_t i, T* a);
  251.  
  252.  
  253.      Adds the object pointed to by aaaa at the index position iiii.  The item
  254.      previously at position iiii is moved to iiii++++1111, eeeettttcccc.  The collection will be
  255.      resized automatically if this causes the number of items to exceed the
  256.      capacity.  The index iiii must be between 0 and the number of items in the
  257.      vector or an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will occur.
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               RWBoolean
  273.           iiiissssEEEEmmmmppppttttyyyy() const;
  274.  
  275.  
  276.      Returns TTTTRRRRUUUUEEEE if there are no items in the collection, FFFFAAAALLLLSSSSEEEE otherwise.
  277.  
  278.               T*&
  279.           llllaaaasssstttt();
  280.           T* const&
  281.           llllaaaasssstttt() const;
  282.  
  283.  
  284.      Returns a pointer to the last item in the collection.  If there are no
  285.      items in the collection then an exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will
  286.      occur.
  287.  
  288.               size_t
  289.           lllleeeennnnggggtttthhhh() const;
  290.  
  291.  
  292.      Returns the number of items currently in the collection.
  293.  
  294.               size_t
  295.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const T* a) const;
  296.  
  297.  
  298.      Performs a linear search, returning the number of objects in the
  299.      collection that are equal to the object pointed to by aaaa.  Equality is
  300.      measured by the class-defined equality operator for type TTTT.
  301.  
  302.               void
  303.           pppprrrreeeeppppeeeennnndddd(T* a);
  304.  
  305.  
  306.      Adds the item pointed to by aaaa to the beginning of the collection.  The
  307.      collection will be resized automatically if this causes the number of
  308.      items to exceed the capacity.
  309.  
  310.               T*
  311.           rrrreeeemmmmoooovvvveeee(const T* a);
  312.  
  313.  
  314.      Performs a linear search, removing the first object which is equal to the
  315.      object pointed to by aaaa and returns a pointer to it, or nnnniiiillll if no such
  316.      object could be found.  Equality is measured by the class-defined
  317.      equality operator for type TTTT.
  318.  
  319.               size_t
  320.           rrrreeeemmmmoooovvvveeeeAAAAllllllll(const T* a);
  321.  
  322.  
  323.      Performs a linear search, removing all objects which are equal to the
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      object pointed to by aaaa.  Returns the number of objects removed.  Equality
  339.      is measured by the class-defined equality operator for type TTTT.
  340.  
  341.               T*
  342.           rrrreeeemmmmoooovvvveeeeAAAAtttt(size_t i);
  343.  
  344.  
  345.      Removes the object at index iiii and returns a pointer to it.  An exception
  346.      of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will be thrown if iiii is not a valid index.  Valid
  347.      indices are from zero to the number of items in the list less one.
  348.  
  349.               T*
  350.           rrrreeeemmmmoooovvvveeeeFFFFiiiirrrrsssstttt();
  351.  
  352.  
  353.      Removes the first item in the collection and returns a pointer to it.  An
  354.      exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will be thrown if the list is empty.
  355.  
  356.               T*
  357.           rrrreeeemmmmoooovvvveeeeLLLLaaaasssstttt();
  358.  
  359.  
  360.      Removes the last item in the collection and returns a pointer to it.  An
  361.      exception of type RRRRWWWWBBBBoooouuuunnnnddddssssEEEErrrrrrrroooorrrr will be thrown if the list is empty.
  362.  
  363.               void
  364.           rrrreeeessssiiiizzzzeeee(size_t N);
  365.  
  366.  
  367.      Changes the capacity of the collection to NNNN.  Note that the number of
  368.      objects in the collection does not change, just the capacity.
  369.  
  370. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss
  371.               RWvostream&
  372.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream& strm,
  373.                  const RWTPtrOrderedVector<T>& coll);
  374.           RWFile&
  375.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile& strm, const RWTPtrOrderedVector<T>& coll);
  376.  
  377.  
  378.      Saves the collection ccccoooollllllll onto the output stream ssssttttrrrrmmmm, or a reference to
  379.      it if it has already been saved.
  380.  
  381.               RWvistream&
  382.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTPtrOrderedVector<T>& coll);
  383.           RWFile&
  384.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTPtrOrderedVector<T>& coll);
  385.  
  386.  
  387.      Restores the contents of the collection ccccoooollllllll from the input stream ssssttttrrrrmmmm.
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))                            RRRRWWWWTTTTPPPPttttrrrrOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.               RWvistream&
  405.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTPtrOrderedVector<T>*& p);
  406.           RWFile&
  407.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTPtrOrderedVector<T>*& p);
  408.  
  409.  
  410.      Looks at the next object on the input stream ssssttttrrrrmmmm and either creates a
  411.      new collection off the heap and sets pppp to point to it, or sets pppp to point
  412.      to a previously read instance.  If a collection is created off the heap,
  413.      then you are responsible for deleting it.
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.